# --*--coding=utf-8 --*--
"""
测试数据关键字解析
"""
from auto_test.lib.date_util import cur_day, add_days, date_to_str


def action(key_word):
    """
    处理请求参数关键字段做转换
    :param key_word:
    :return:
    """
    if key_word is None:
        return
    key = key_word.lower()
    if key == '$today':
        return date_to_str(cur_day)
    if key == '$yesterday':
        return add_days(days=-1)
    if key == '$tomorrow':
        return add_days(days=1)
    if key == '$a_week_later':
        return add_days(days=7)
    if key == '$a_week_ago':
        return add_days(days=-7)
    if key == '$a_year_later':
        return add_days(days=365)
    return key
